package com.miracle9.game.thread;

import com.miracle9.game.server.message.MessageSend;
import com.miracle9.game.server.message.StorageMethodEntity;
import com.miracle9.game.util.GameParameterAssist;
import org.apache.mina.core.session.IoSession;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;

//@Service("sessionHearThread")
public class SessionHearThread  extends Thread{


    @PostConstruct
    public void sessionThreadStart() {
        start();
    }

    public void run() {
     /*       for (Map.Entry<Integer, IoSession> entry : GameParameterAssist.ba.entrySet()) {
                MessageSend.q.notifyAllOperating(new StorageMethodEntity(entry.getValue(), "xxheart", new Object[]{"1"}));
            }*/
            while(true){
                try {
                    for (IoSession as : GameParameterAssist.ba.values()) {
                        MessageSend.q.notifyAllOperating(new StorageMethodEntity(as, "xxheart", new Object[]{"1"}));
                    }
                    Thread.sleep(1000);
                }catch (Exception e){
                    e.printStackTrace();
                }

            }
    }
}
